<?php

function bank_delete($id)
{
	$result = array();
	
	mysql_query("delete from `atm` where `bank_id` = '$id'");
	$result['atm'] = mysql_affected_rows();
	mysql_query("delete from `credit_currency` where `type` = '2' and `credit_id` in (select `auto_id` from `auto` where `bank_id` = '$id')");
	mysql_query("delete from `auto` where `bank_id` = '$id'");
	$result['auto'] = mysql_affected_rows();
	mysql_query("delete from `credit_currency` where `type` = '5' and `credit_id` in (select `business_id` from `business` where `bank_id` = '$id')");
	mysql_query("delete from `business` where `bank_id` = '$id'");
	$result['business'] = mysql_affected_rows();
	mysql_query("delete from `credit_currency` where `type` = '4' and `credit_id` in (select `cart_id` from `cart` where `bank_id` = '$id')");
	mysql_query("delete from `cart` where `bank_id` = '$id'");
	$result['cart'] = mysql_affected_rows();
	mysql_query("delete from `credit_currency` where `type` = '1' and `credit_id` in (select `credit_id` from `credit` where `bank_id` = '$id')");
	mysql_query("delete from `credit` where `bank_id` = '$id'");
	$result['credit'] = mysql_affected_rows();
	mysql_query("delete from `credit_currency` where `type` = '3' and `credit_id` in (select `home_id` from `home` where `bank_id` = '$id')");
	mysql_query("delete from `home` where `bank_id` = '$id'");
	$result['home'] = mysql_affected_rows();
	mysql_query("delete from `rko` where `bank_id` = '$id'");
	$result['rko'] = mysql_affected_rows();
	mysql_query("delete from `vacancy` where `bank_id` = '$id'");
	$result['vacancy'] = mysql_affected_rows();
	
	mysql_query("delete from `bank` where `bank_id` = '$id'");
	$result['bank'] = mysql_affected_rows();
	
	return $result;
}

function credit_delete($id,$type)
{
	$result = array();
	
	switch($type)
	{
		case 1: $query = "delete from `credit` where `credit_id` = '$id'"; break;
		case 2: $query = "delete from `auto` where `auto_id` = '$id'"; break;
		case 3: $query = "delete from `home` where `home_id` = '$id'"; break;
		case 4: $query = "delete from `cart` where `cart_id` = '$id'"; break;
		case 5: $query = "delete from `business` where `business_id` = '$id'"; break;
	}
	mysql_query("delete from `credit_currency` where `type` = '$type' and `credit_id` = '$id'");
	$result['currency'] = mysql_affected_rows();
	mysql_query($query);
	$result['credit'] = mysql_affected_rows();
	
	return $result;
}

function deposit_delete($id)
{
	$result = array();
	mysql_query("delete from `deposit_percent` where `deposit_id` = '$id'");
	$result['percents'] = mysql_affected_rows();
	mysql_query("delete from `deposit` where `deposit_id` = '$id' limit 1");
	$result['deposit'] = mysql_affected_rows();
	
	return $result;
}


?>